package com.smartleanx.module.hrm.controller.admin.tenant;

import com.smartleanx.framework.common.pojo.CommonResult;
import com.smartleanx.module.hrm.controller.admin.tenant.vo.TenantSaveReqVO;
import com.smartleanx.module.hrm.intergration.TenantServiceProvider;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.smartleanx.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 劳安心租户")
@RestController
@RequestMapping("/hrm/tenant")
public class TenantController {

    @Resource
    private TenantServiceProvider tenantServiceProvider;

    @PostMapping("/create")
    @Operation(summary = "创建租户")
    @PreAuthorize("@ss.hasPermission('system:tenant:create')")
    public CommonResult<Long> createTenant(@Valid @RequestBody TenantSaveReqVO createReqVO) {
        return success(tenantServiceProvider.createTenant(createReqVO));
    }

    @PostMapping("/bpm-update")
    public CommonResult<Long> updateTenantBpm(@RequestParam long tenantId) {
        return success(tenantServiceProvider.updateTenantBpm(tenantId));
    }
}
